#ifndef _FUSION_H_
#define _FUSION_H_

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include "route.h"
#include "resource.h"

/*-------------------------definition-------------------------*/
#define fire_sensor_num 3
#define GET_ARRAY_LEN(array) sizeof(array) / sizeof(array[0]) //计算数组长度

#define PM10   0x00
#define PM2_5  0x01
#define AIR_CO 0x02
#define NO2    0x03
#define O3     0x04
#define SO2    0x05
#define air_quality_evaluate_index_num 2
#define air_quality_sensor_num         6
/*-------------------------return value-------------------------*/
#define RETVAL_FUSION_FAILED 0              //return value: failed to 
#define RETVAL_FUSION_SUCCESSFULLY 1        //return value: successfully

typedef unsigned char uint8_t;

/*data pre-processing algorithm*/
#define P_Q 1
#define M_R 1
double KalmanFilter(double ResrcData);
double data_pre_processing(double data[],int len);

/*fire enviroment*/
float Membership(float data, float x1, float x2, float x3, float y1, float y2);
float data_fusion(float Fire_data[]);
double mean(double data[], int length);

/*air quality evaluate enviroment*/
float get_aqi_interval(int params_arr[], float value, int max);
float *AQI_Weight(float AQI_array[]);
float calculate_AQI(int type, float value);
float AQI_fusion(float data[]);

/*water quality evaluation function*/
float *calculate_water_Weight(float Water_array[]);
float cal_water_index(int type, float value);
float get_water_interval(float params_arr[], float value, int max);
float *water_fusion(float data[]);

/*Control related*/
int cooperative_control(float fusion_result);
#endif 